import request from '/@/utils/request';


export function useDeptApi() {
	return {
		// 获取所有部门
		getAllDepts:(params?:object)=>{
			return request({
				url: 'dept/all/tree',
				method: 'get',
				params
			});
		},
		getDepts: (params?:object) => {
			return request({
				url: 'dept/',
				method: 'get',
				params
			});
		},
		// 树状查询部门
		getDeptTree:(params?:object)=>{
			return request({
				url:'dept/tree',
				method:'get',
				params
			})
		},
		// 获取所有上级部门
		getUpper:(id:number)=>{
			return request({
				url:`dept/upper/${id}`,
				method:'get'
			})
		},
		// 新增部门
		addDept:(data:object)=>{
			return request({
				url:'dept/',
				method:'post',
				data
			})
		},
		// 更新部门
		updateDept:(data:object)=>{
			return request({
				url:'dept/',
				method:'put',
				data
			})
		},
		// 删除部门
		deleteDept:(data:object)=>{
			return request({
				url:'dept/',
				method:'delete',
				data
			})
		},
	};
}
